/* template: generate the related code and return as string */

const template_py_create = (id, parent_id, type) => {
    return `${id} = lv.${type}(${parent_id})`;
}

const template_py_setter_number = (id, attr, param) => {
    return `${id}.set_${attr}(${param})`;
}

const template_py_setter_boolean = (id, attr, param) => {
    let value = "True";
    if (param == false) {
        value = "False";
    }
    return `${id}.set_${attr}(${value})`;
}

const template_py_setter_text = (id, attr, param) => {
    return `${id}.set_${attr}("${param}")`;
}

const template_py_setter_simple = (id, attr, param) => {
    return `${id}.set_${attr}(${param})`;
}

const template_c_create = (id, parent_id, type) => {
    return `lv_obj_t * ${id} = lv_${type}_create(${parent_id}, NULL);`;
}

const template_c_setter_simple = (id, type, attr, param) => {
    return `lv_${type}_set_${attr}(${id}, ${param});`;
}

const template_py_cb = (id) => {
    return `${id}.set_event_cb(lambda : ) #Put your code here`
}

const template_c_cb = (id) => {
    return `static void ${id}_event_cb(lv_obj_t * ${id}, lv_event_t event)
{
    // Write the event handler here
    // if(event == LV_EVENT_) { }
}`;
}


const template_c_all = (body, cb) => {
    return `
/**
 * @file lv_gui.h
 * Generated By WALV
 */

#ifndef LV_GUI_H
#define LV_GUI_H

#ifdef __cplusplus
extern "C" {
#endif

#include "/*Put the path to lvgl.h here*/"

/**********************
 *   CALLBACK
 **********************/
${cb}
/**********************
 *   GLOBAL FUNCTIONS
 **********************/
${body}

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /*LV_GUI_H*/
`
}